{% extends "element/saas/base_mini.html" %}

{% block meta_title %}个体户多维筛查{% endblock %}

{% block header %}{% endblock %}
{% block siderbar %}{% endblock %}
{% block footer %}{% endblock %}

{% block main %}
    <style>
        body {
            background: none;
        }
        #form_search #se_table td {
            padding: 2px 5px;
        }
        .admin-content {
            padding: 0;
            border: none;
        }
    </style>
    <div class="admin-content">
        <div style="padding-top:3px;">
            <form id="form_search" method="post" style="padding:5px 0 12px 2px;margin-bottom: 2px;">
                <table id="se_table">
                    <tr class="se_tr">
                        <td class="se_title">个体户名称：</td>
                        <td class="se_input" style="width: 22%;">
                            <input name="ENTNAME" class="mini-autocomplete" valueField="ENTNAME" textField="ENTNAME"
                                   url="/getimohu/" emptyText="支持模糊查询"
                                   popupEmptyText="查无数据" loadingText="加载中..." vtype="rangeLength:2,100">
                        </td>
                        <td style="width: 2%;"></td>
                        <td class="se_title">注册号：</td>
                        <td class="se_input" style="width: 22%;">
                            <input name="REGNO" class="mini-textbox" emptyText="完整注册号" vtype="rangeLength:8,32">
                        </td>
                        <td style="width: 2%;"></td>
                        <td class="se_title">主营业务：</td>
                        <td class="se_input" style="width: 22%;">
                            <input name="OPSCOPE" class="mini-textbox" vtype="rangeLength:2,20" emptyText="关键词模糊查询">
                        </td>
                    </tr>
                    <tr class="se_tr">
                        <td class="se_title">所在地区：</td>
                        <td class="se_select">
                            {% include "element/saas/includes/input_region.html" %}
                        </td>
                        <td></td>
                        <td class="se_title">行业分类：</td>
                        <td class="se_select">
                            {% include "element/saas/includes/input_nic.html" %}
                        </td>
                        <td></td>
                        <td class="se_title">开业日期：</td>
                        <td class="se_range">
                            <input name="ESDATE1" class="mini-datepicker" allowinput="false"
                                   ondrawdate="onDrawDate" style="width:45%;float:left;"/>
                            <span class="se_line">一</span>
                            <input name="ESDATE2" class="mini-datepicker" allowinput="false"
                                   ondrawdate="onDrawDate" style="width:45%;float:left;"/>
                        </td>
                    </tr>
                    <tr class="se_tr">
                        <td class="se_title">个体户状态</td>
                        <td class="se_select">
                            <input name="ENTSTATUS" class="mini-combobox" showNullItem="true"
                                   url="/static/element/saas/form_render/entstatus.json"/>
                        </td>
                        <td></td>
                        <td class="se_title">注册资金：</td>
                        <td class="se_range">
                            <input name="REGCAP1" class="mini-textbox" style="width:45%;float:left;"
                                   vtype="range:0,10000000" emptyText="万元"/>
                            <span class="se_line">一</span>
                            <input name="REGCAP2" class="mini-textbox" style="width:45%;float:left;"
                                   vtype="range:0,10000000" emptyText="万元"/>
                        </td>
                        <td></td>
                        <td></td>
                        <td style="text-align: center;">
                            <a class="mini-button" plain="true" onclick="elreload()" iconCls="icon-select"
                               style="margin-right: 30px;">清除</a>
                            <a class="mini-button" plain="true" onclick="Adsearch()"
                               iconCls="icon-zoomin">查找</a>
                        </td>
                    </tr>
                </table>
            </form>

            <div id="datagrid_main" class="mini-datagrid" url="/saas/geti_list/?method=loadtable" idField="entid"
                 allowResize="true" multiSelect="true" showColumnsMenu="true" pageSize="20"
                 sizeList="[20,80,200,500]" virtualScroll="true">
                <div property="columns">
                    <div type="checkcolumn"></div>
                    <div field="entid" width="50" hideable="true" visible="false">序号</div>
                    <div field="REGNO" width="80">注册号</div>
                    <div field="ENTNAME" width="180" hideable="true">个体户名称</div>
                    <div field="region_id" width="80">所在地区</div>
                    <div field="nic_id" width="140">行业分类</div>
                    <div field="REGCAP" width="60" allowSort="true">注册资金(元)</div>
                    <div field="ENTSTATUS" width="60">个体户状态</div>
                    <div field="ESDATE" width="75" dateFormat="yyyy-MM-dd">开业日期</div>
                    <div field="faren" width="70">负责人</div>
                    <div field="farentel" width="70">负责人电话</div>
                    <div field="OPSCOPE" width="180">主营业务</div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block footer_js %}
    <script type="text/javascript">
        mini.parse();
        var grid_main = mini.get("datagrid_main");
        var tabs = mini.get("mainTabs");
        var form_search = new mini.Form("form_search");
        top["win"] = window;
        grid_main.load();

        function Adsearch() {
            form_search.validate();
            if (form_search.isValid() == false) return;
            var sfield = 'ENTNAME￥REGNO￥region_id￥nic_id￥ENTSTATUS￥OPSCOPE￥REGCAP￥ESDATE';
            {#生成搜索数据#}
            var svalue = fclean(mini.getbyName("ENTNAME").getValue()) + '￥'
                    + fclean(mini.getbyName("REGNO").getValue()) + '￥'
                    + fclean(mini.getbyName("region_id").getValue()) + '￥'
                    + fclean(mini.getbyName("nic_id").getValue()) + '￥'
                    + fclean(mini.getbyName("ENTSTATUS").getValue()) + '￥'
                    + fclean(mini.getbyName("OPSCOPE").getValue()) + '￥'
                    + fclean(mini.getbyName("REGCAP1").getValue()) + '$' + fclean(mini.getbyName("REGCAP2").getValue()) + '￥'
                    + fclean(mini.formatDate(mini.getbyName("ESDATE1").getValue(), "yyyy-MM-dd")) + '$'
                    + fclean(mini.formatDate(mini.getbyName("ESDATE2").getValue(), "yyyy-MM-dd"));
            if (svalue != '￥￥￥￥￥￥$￥$') {
                grid_main.load({sfield: sfield, svalue: svalue});
            }
        }

        // 筛选器的清除按钮
        function elreload() {
            grid_main.load({pageIndex: 0, pageSize: 20, sortField: " ", sortOrder: "desc"});
            form_search.clear();
        }
        {#    //导出excel#}
        function getdata2() {
            var FileName = "个体户筛查结果-{{ sitesettings.website_name }}-" + window.Owner.gettime();
            var JSONData = grid_main.data;
            //先转化json
            var arrData2 = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
            var headers2 = {
                "ENTNAME": "个体户名称", "REGNO": "注册号", "region_id": "所在地区", "nic_id": "行业分类",
                "REGCAP": "注册资金(万)", "ENTSTATUS": "个体户状态", "ESDATE": "开业日期", "faren": "负责人",
                "farentel": "负责人电话", "OPSCOPE": "主营业务"
            };
            var arrKey2 = ["ENTNAME", "REGNO", "region_id", "nic_id", "REGCAP", "ENTSTATUS", "ESDATE", "faren", "farentel", "OPSCOPE"];
            if (arrData2[0]["ENTNAME"] != "个体户名称") {
                arrData2.unshift(headers2);
            }
            if (window.Owner.isIEexcel()) {
                window.Owner.exportExcelIE(arrData2, arrKey2, FileName);
            } else {
                window.Owner.downloadExl(arrData2, arrKey2, FileName);
            }
        }
    </script>
    {{ block.super }}
{% endblock %}
